#!/bin/bash
#file : readres.sh
# ./readres.sh <configfile>

getdns(){
iplist=`cat $1 | awk '{print $2}' | grep -vi "[a-z]" | sort -u |grep ^[0-9] `
for ip in $iplist ; do
dns=`nslookup $ip |  grep name | awk '{print $NF}' `
if [  "$dns" ] ; then
sed -i "s/$ip/$dns/g" $1
fi
done

}

mycat(){
cifs_dirs=`cat $1 | grep -v '#' | awk '{print $3}' | grep cifs `
cd $cifs_dirs
cat fmtout_445.ALLOWED.genouthosts 

cd ../main
cat fmtout_OBSERVED.genouthosts
cat fmtout_policy_denied.genouthosts
cat fmtout_policy_denied.genoutclients
cat fmtout_policy_denied.genoutclients.details

cd ../ssl
cat fmtout_OBSERVED.genouthosts
cat fmtout_policy_denied.genouthosts
cat fmtout_policy_denied.genoutclients
cat fmtout_policy_denied.genoutclients.details
}

mycat $1 | grep -v "#" > mycat_temp
getdns mycat_temp
cat mycat_temp
rm -f mycat_temp
